<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.1</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
      <!--百度ueditor-->
    <script src="__ADMIN__/plus/ueditor/ueditor.config.js"></script>
    <script src="__ADMIN__/plus/ueditor/ueditor.all.min.js"></script>

    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
  </head>
  <body>
    <div class="x-body">
        <form class="layui-form" lay-filter="form">
          <input type="hidden" name="id" value="{$articles.id}" />

          <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>工作总结</legend>
          </fieldset>

          <!-- <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  内容
              </label>
              <div class="layui-input-block">
                  <textarea type="text" name="content" id="content"></textarea>
              </div>
          </div> -->    
          {if condition="$_SESSION['admin']['group_id'] neq 1 "}
          <div class="layui-form-item">
              <!-- <label for="L_repass" class="layui-form-label">
              </label> -->
            <button type="button" class="layui-btn" id="upload-btn"><i class="layui-icon"></i>选择文件</button>
          </div>
          {/if}
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                <a href="{$articles.content}" target="_blank">下载</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="https://view.officeapps.live.com/op/view.aspx?src=http://oa.twjha.cn{$articles.content}" target="_blank">预览</a>
                
              </label>
              <div class="layui-input-inline" style="width:390px"> 
              
              <input type="text" name="content" value="{$articles.content}" readonly style="border:0" autocomplete="off" class="layui-input">
              
              </div>
          </div>
          

          {if condition="$_SESSION['admin']['group_id'] eq 1 || $_SESSION['admin']['group_id'] eq 5"}
          <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>批注</legend>
          </fieldset>       
          
          <div class="layui-form-item layui-form-text">
              <!-- <label for="L_repass" class="layui-form-label">
              </label> -->
              <div class="layui-input-block" style="margin-left:0">
                <textarea  class="" id="pizhu_text" name="pizhu_text">{$articles.pizhu_text}</textarea>
              </div>
          </div>

          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
                上传批注文档
              </label>
            <button type="button" class="layui-btn layui-btn-primary" id="upload-btn-1"><i class="layui-icon"></i>选择文件</button>
          </div>

          <div class="layui-form-item" id="preview-btn" {if condition="!$articles.pizhu"}style="display:none"{/if} >
              <label for="L_repass" class="layui-form-label">
                <a href="{$articles.pizhu}" target="_blank">下载</a>
              </label>
              <div class="layui-input-inline" style="width:390px"> 
              
              <input type="text" name="pizhu" value="{$articles.pizhu}" readonly style="border:0" autocomplete="off" class="layui-input">
              
              </div>
          </div>

          {/if}


          <div class="layui-form-item">
              <!-- <label for="L_repass" class="layui-form-label">
              </label> -->
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  确定
              </button>
          </div>
      </form>
    </div>
    <script>
        //实例化编辑器
        UE.getEditor('pizhu_text',{initialFrameWidth:'99%',initialFrameHeight:270});

        layui.use(['form','layer','upload'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer
          ,upload = layui.upload;

          upload.render({
            elem: '#upload-btn'
            ,url: '{:url('ds/upload')}' 
            ,accept: 'file' 
            ,exts: 'doc|docx' 
            ,multiple: true
            ,done: function(res){

              if(res.status == 1)
              {
                //alert(res.filename);
                form.val('form', {
                  "content": res.filename
                });
                $('#preview-btn a').attr('href',res.previewUrl);
                $('#preview-btn').show();
              }
              layer.msg(res.msg);
              
              //console.log(res)
            }
          });

          upload.render({
            elem: '#upload-btn-1'
            ,url: '{:url('ds/upload')}' 
            ,accept: 'file' 
            ,exts: 'doc|docx' 
            ,multiple: true
            ,done: function(res){

              if(res.status == 1)
              {
                //alert(res.filename);
                form.val('form', {
                  "pizhu": res.filename
                });
                $('#preview-btn a').attr('href',res.previewUrl);
                $('#preview-btn').show();
              }
              layer.msg(res.msg);
              
              //console.log(res)
            }
          });


          //监听提交
          form.on('submit(add)', function(data){
            $.ajax({
                type:'POST',
                dataType:'json',
                data:{data:data.field},
                url:"{:url('Work/add')}",
                success:function(obj){
                  layer.msg(obj.msg, {icon: obj.icon,time:1500},function(){
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    // 可以对父窗口进行刷新 
                    x_admin_father_reload();
                    // location.reload();
                  });
                }
            });
            return false;
          });
          
        });
    </script>
  </body>

</html>